home *** CD-ROM | disk | FTP | other *** search
/ PC/CD Gamer UK 129 / CD Gamer Issue 129 (December 2003) (Disc 1).ISO / Addons / Vietcong Map editor / max plugins / ui / macroscripts / Macro_PteroProps.mcr
Encoding:
Text File  |  2003-09-10  |  27.9 KB  |  848 lines

  1. ---------------------------------------------------------------
  2. --
  3. -- PteroProps
  4. --
  5. -- by Pan Collette
  6. --
  7. -- Create: 13.01.2003
  8. -- Modified: 06.09.2003
  9. --
  10. ---------------------------------------------------------------
  11.  
  12. macroscript PteroProps category:"PteroTools"
  13. buttonText:"PteroProps"
  14. toolTip:"Open PteroProps Panel"
  15. icon:#("pteroTools", 1)
  16. (
  17.     if _isPteroPropsOpen == undefined do _isPteroPropsOpen = false
  18.     if not _isPteroPropsOpen do (
  19.         global _isPteroPropsOpen
  20.         global _mainWidth    = 180
  21.         global _mainHeight    = _mainWidth * 2.5
  22.         global _mainOffset    = 8
  23.         global _maxRows        = 4
  24.         global _usedRows    = 1
  25.         global _rollouts    = #()
  26.         
  27.         local version        = 0.8
  28.         local scriptPath    = ( GetDir #scripts ) + "\\pteroTools"
  29.         local iconPath        = ( GetDir #scripts ) + "\\pteroTools"
  30.         local iniPath        = ( GetDir #plugcfg )
  31.         local _logFile        = scriptPath + "\\!_listener_!.log"
  32.         local _iniFile        = iniPath + "\\pteroCollette.ini"
  33.         local _defFile        = iniPath + "\\pteroCollette.ini"
  34.         local _matFile        = iniPath + "\\pteroColMat.ini"
  35.         local _iniSect        = "PteroProps"
  36.         local _defSect        = "PropsDefs"
  37.         local _lckIcon        = #( ( iconPath + "\\pin13i.bmp" ), ( iconPath + "\\pin13a.bmp" ), 4, 3, 2, 4, 1 )
  38.         local _setIcon        = #( ( iconPath + "\\set13i.bmp" ), ( iconPath + "\\set13a.bmp" ), 4, 3, 2, 4, 1 )
  39.         local _defIcon        = #( ( iconPath + "\\def13i.bmp" ), ( iconPath + "\\def13a.bmp" ), 4, 3, 2, 4, 1 )
  40.         local _savIcon        = #( ( iconPath + "\\sav13i.bmp" ), ( iconPath + "\\sav13a.bmp" ), 4, 3, 2, 4, 1 )
  41.         local _delIcon        = #( ( iconPath + "\\del13i.bmp" ), ( iconPath + "\\del13a.bmp" ), 4, 3, 2, 4, 1 )
  42.         local _acqIcon        = #( ( iconPath + "\\acq13i.bmp" ), ( iconPath + "\\acq13a.bmp" ), 4, 3, 2, 4, 1 )
  43.         local _tpeIcon        = #( ( iconPath + "\\tpe13i.bmp" ), ( iconPath + "\\tpe13a.bmp" ), 4, 3, 2, 4, 1 )
  44.         local _eol            = bit.intAsChar 13
  45.         local _oldKeyString    = 1
  46.         local _keyName        = 2
  47.         local _firstValue    = 3
  48.         
  49.         -----------------------------------------------
  50.         -- fnCompWidth()
  51.         -----------------------------------------------
  52.         fn fnCompWidth w = (
  53.             local nw = _mainWidth
  54.             for n = 1 to _maxRows do
  55.                 if w >= _mainWidth * n do (
  56.                     nw = _mainWidth * n
  57.                     _usedRows = n
  58.                 )
  59.             return nw
  60.         )
  61.         
  62.         -----------------------------------------------
  63.         -- fnClearProps()
  64.         -----------------------------------------------
  65.         fn fnClearProps obj = (
  66.                 local pteroBuffer = getUserPropBuffer obj
  67.                 local n = 1
  68.  
  69.                 while n < pteroBuffer.count do 
  70.                     if ( subString pteroBuffer n 1 ) == " " then ( pteroBuffer = ( replace pteroBuffer n 1 "") ) else n += 1
  71.  
  72.                 setUserPropBuffer obj pteroBuffer
  73.                 return pteroBuffer
  74.         )
  75.  
  76.         -----------------------------------------------
  77.         -- fnReadProp()
  78.         -----------------------------------------------
  79.         fn fnReadProp obj key num:1 = (
  80.             try (
  81.                 local strArray    = #( key, key )
  82.                 local userProps
  83.                 
  84.                 fnClearProps obj
  85.                 strArray[_oldKeyString] += "=" + ( userProps = ( getUserProp obj key ) as string) 
  86.                 strArray += filterString userProps " ,"
  87.  
  88.                 for n = _firstValue to strArray.count do
  89.                     if not ( strArray[n] as float ) == undefined then strArray[n] = strArray[n] as float
  90.  
  91.                 return strArray
  92.             ) catch (
  93.                 if _DEBUG_ do (
  94.                     format "-- Error: fnReadProp()\n"
  95.                     format "--\tobj: %\n" obj
  96.                     format "--\tkey: %\n" key
  97.                     format "--\tnum: %\n" num
  98.                     format "--\tstrArray: %\n" strArray
  99.                     format "--\tuserProps: %\n" userProps 
  100.                     format "--\tn: %\n" n
  101.                     format "\n"
  102.                 )
  103.                 return #("","","")
  104.             )
  105.         )
  106.  
  107.         -----------------------------------------------
  108.         -- fnWriteProp()
  109.         -----------------------------------------------
  110.         fn fnWriteProp obj strArray = (
  111.             try (
  112.                 local pteroBuffer    = fnClearProps obj
  113.                 local valString        = strArray[_firstValue]
  114.                 
  115.                 if strArray[_oldKeyString] == "" and not ( substring pteroBuffer ( pteroBuffer.count - 1 ) 1 ) == _eol do
  116.                     strArray[_keyName] = _eol + ( bit.intAsChar 10 ) + strArray[_keyName]
  117.                 if _firstValue < strArray.count do
  118.                     for n = ( _firstValue + 1 ) to strArray.count do valString += "," + strArray[n]
  119.  
  120.                 setUserProp obj strArray[_keyName] valString
  121.                 fnClearProps obj
  122.                 return true
  123.             ) catch (
  124.                 if _DEBUG_ do (
  125.                     format "-- Error: fnWriteProp()\n"
  126.                     format "--\tobj: %\n" obj
  127.                     format "--\tstrArray: %\n" strArray
  128.                     format "--\tpteroBuffer: %\n" pteroBuffer 
  129.                     format "--\tvalString: %\n" valString
  130.                     format "\n"
  131.                 )
  132.                 return false
  133.             )
  134.         )
  135.         
  136.         -----------------------------------------------
  137.         -- fnDeleteProp()
  138.         -----------------------------------------------
  139.         fn fnDeleteProp obj key = (
  140.             try (
  141.                 local strArray        = fnReadProp obj key
  142.                 local pteroBuffer    = getUserPropBuffer obj
  143.                 local keyStart        = findString pteroBuffer strArray[_oldKeyString]
  144.                 local keyLength        = strArray[_oldKeyString].count
  145.                 
  146.                 if strArray[_firstValue] as string == "undefined" do return false
  147.                 if ( substring pteroBuffer ( keyStart + keyLength ) 1 ) == _eol do keyLength += 2
  148.                 
  149.                 pteroBuffer = replace pteroBuffer keyStart keyLength ""
  150.                 setUserPropBuffer obj pteroBuffer
  151.                 return true
  152.             ) catch (
  153.                 if _DEBUG_ do (
  154.                     format "-- Error: fnDeleteProp()\n"
  155.                     format "--\tobj: %\n" obj
  156.                     format "--\tkey: %\n" key
  157.                     format "--\tstrArray: %\n" strArray
  158.                     format "--\tpteroBuffer: %\n" pteroBuffer 
  159.                     format "--\tkeyStart: %\n" keyStart
  160.                     format "--\tkeyLength: %\n" keyLength
  161.                     format "\n"
  162.                 )
  163.                 return false
  164.             )
  165.         )
  166.         
  167.         -----------------------------------------------
  168.         -- fnSaveINI2()
  169.         -----------------------------------------------
  170.          fn fnSaveINI2 key val = (
  171.             try (
  172.                 local res = setINISetting _iniFile _iniSect key val
  173.                 return res
  174.             ) catch (
  175.                 if _DEBUG_ do (
  176.                     format "-- Error: fnSaveINI2()\n"
  177.                     format "--\tkey: %\n" key
  178.                     format "--\tval: %\n" val
  179.                     format "--\tres: %\n" res
  180.                     format "--\t_iniFile: %\n" _iniFile
  181.                     format "--\t_iniSect: %\n" _iniSect
  182.                     format "\n"
  183.                 )
  184.                 return false
  185.             )
  186.         )
  187.  
  188.         -----------------------------------------------
  189.         -- fnLoadINI2()
  190.         -----------------------------------------------
  191.          fn fnLoadINI2 key = (
  192.             try (
  193.                 local val = execute ( getINISetting _iniFile _iniSect key )
  194.                 return val
  195.             ) catch (
  196.                 if _DEBUG_ do (
  197.                     format "-- Error: fnLoadINI2()\n"
  198.                     format "--\tkey: %\n" key
  199.                     format "--\tval: %\n" val
  200.                     format "--\t_iniFile: %\n" _iniFile
  201.                     format "--\t_iniSect: %\n" _iniSect
  202.                     format "\n"
  203.                 )
  204.                 return false
  205.             )
  206.         )
  207.  
  208.         -----------------------------------------------
  209.         -- fnSetControlValue()
  210.         -----------------------------------------------
  211.         fn fnSetControlValue ro key value type:1 = (
  212.             if ( local keyNo = findItem ro.controls key ) == 0 do return false
  213.  
  214.             try (
  215.                 
  216.                 fn fnDoBoolean value:value                                = case of (
  217.                                                                                 ( ( classof value ) == booleanClass ):        value
  218.                                                                                 ( ( value as integer ) == 1 ):                true
  219.                                                                                 ( fnDncase ( value as string ) == "true" ):    true
  220.                                                                                 default:                                    false
  221.                                                                             )
  222.                 fn fnDoListBox ro:ro keyNo:keyNo value:value type:type    = case type of (
  223.                                                                                 0:    ro.controls[keyNo].items            = if classof value == array then value else ( print "Error: fnSetControlValue() - no Array Value"; return false )
  224.                                                                                 1:    try ( ro.controls[keyNo].selection    = value as integer ) catch ( print "Error: fnSetControlValue() - no Integer Value"; return false )
  225.                                                                                 2:    ro.controls[keyNo].selected            = value as string
  226.                                                                             )
  227.                 case ( classof key ) of (
  228.                     CheckBoxControl:         ro.controls[keyNo].state        = fnDoBoolean()
  229.                     CheckButtonControl:     ro.controls[keyNo].state        = fnDoBoolean()
  230.                     RadioControl:            ro.controls[keyNo].state        = fnDoBoolean()
  231.                     ComboBoxControl:        fnDoListBox()
  232.                     ListBoxControl:            fnDoListBox()
  233.                     EditTextControl:        ro.controls[keyNo].text            = value as string
  234.                     LabelControl:            ro.controls[keyNo].text            = value as string
  235.                     SpinnerControl:         try ( ro.controls[keyNo].value    = value as float ) catch ( print "Error: fnSetControlValue() - no Float Value"; return false )
  236.                     ColorPickerControl:        try ( ro.controls[keyNo].color    = value as color ) catch ( print "Error: fnSetControlValue() - no Color Value"; return false )
  237.                     default:                return false
  238.                 )
  239.                 
  240.                 return true
  241.             ) catch (
  242.                 if _DEBUG_ do (
  243.                     format "-- Error: fnSetControlValue()\n"
  244.                     format "--\tro: %\n" ro
  245.                     format "--\tkey: %\n" key
  246.                     format "--\tval: %\n" val
  247.                     format "--\ttype: %\n" type
  248.                     format "--\tkeyNo: %\n" keyNo
  249.                     format "\n"
  250.                 )                 return false
  251.             )
  252.         )
  253.  
  254.         -----------------------------------------------
  255.         -- fnGetControlValue()
  256.         -----------------------------------------------
  257.         fn fnGetControlValue ro key type:1 = (
  258.             if ( local keyNo = findItem ro.controls key ) == 0 do return undefined
  259.  
  260.             try (
  261.                 fn fnDoBoolean ro:ro keyNo:keyNo            = if ro.controls[keyNo].state then 1 else 0
  262.                 fn fnDoListBox ro:ro keyNo:keyNo type:type    = case type of (
  263.                                                                                 0:    ro.controls[keyNo].items
  264.                                                                                 1:    ro.controls[keyNo].selection
  265.                                                                                 2:    ro.controls[keyNo].selected
  266.                                                                             )
  267.                 return case ( classof key ) of (
  268.                     CheckBoxControl:         fnDoBoolean()
  269.                     CheckButtonControl:     fnDoBoolean()
  270.                     RadioControl:            fnDoBoolean()
  271.                     ComboBoxControl:        fnDoListBox()
  272.                     ListBoxControl:            fnDoListBox()
  273.                     EditTextControl:        ro.controls[keyNo].text
  274.                     LabelControl:            ro.controls[keyNo].text
  275.                     SpinnerControl:         ro.controls[keyNo].value
  276.                     ColorPickerControl:        ro.controls[keyNo].color
  277.                     default:                undefined
  278.                 )
  279.             ) catch (
  280.                 if _DEBUG_ do (
  281.                     format "-- Error: fnGetControlValue()\n"
  282.                     format "--\tro: %\n" ro
  283.                     format "--\tkey: %\n" key
  284.                     format "--\ttype: %\n" type
  285.                     format "--\tkeyNo: %\n" keyNo
  286.                     format "\n"
  287.                 )
  288.                 return undefined
  289.             )
  290.         )
  291.         
  292.         -----------------------------------------------
  293.         -- fnAppendRollOut()
  294.         -----------------------------------------------
  295.         fn fnAppendRollOut ro roName c:true = try (
  296.             local tmp, fFile, str
  297.             
  298.             tmp            = #( ro, roName, ( ( ro.fnKeyNames() ).count ), c )
  299.             if c then append _rollouts tmp else insertItem tmp _rollouts 1
  300.  
  301.             return true
  302.         ) catch (
  303.             if _DEBUG_ do (
  304.                 format "-- Error: fnAppendRollOut()\n"
  305.                 format "--\tro: %\n" ro
  306.                 format "--\troName: %\n" roName
  307.                 format "--\tc: %\n" c
  308.                 format "--\ttmp: %\n" tmp
  309.                 format "--\tfFile: %\n" fFile
  310.                 format "--\tstr: %\n" str
  311.                 format "\n"
  312.             )
  313.             return false
  314.         )
  315.         
  316.         -----------------------------------------------
  317.         -- fnFindRollOut()
  318.         -----------------------------------------------
  319.         fn fnFindRollOut ro = try (
  320.             local r = undefined
  321.             for n in _rollouts do (
  322.                 if n[1] == ro do r = n
  323.                 if r != undefined do exit
  324.             )
  325.             return r
  326.         ) catch (
  327.             if _DEBUG_ do (
  328.                 format "-- Error: fnFindRollOut()\n"
  329.                 format "--\tro: %\n" ro
  330.                 format "--\tr: %\n" r
  331.                 format "--\tn: %\n" n
  332.                 format "\n"
  333.             )
  334.             return undefined
  335.         )
  336.         
  337.         -----------------------------------------------
  338.         -- fnCloseRollOut()
  339.         -----------------------------------------------
  340.         fn fnCloseRollOut ro = (
  341.             local r        = fnFindRollOut ro
  342.  
  343.             if _DEBUG_ do format "fnCloseRollOut - ro: %\tr: %\n" ro r
  344.              try (
  345.                 fnSaveINI2 ( r[2] + "RolledUp" ) ( ( not ro.open ) as string )
  346.                 try ( fnSaveINI2 ( r[2] + "Auto" ) ( ro.btnAuto.checked as string ) ) catch ()
  347.                 return true
  348.             ) catch (
  349.                 if _DEBUG_ do (
  350.                     format "-- Error: fnCloseRollOut()\n"
  351.                     format "--\tro: %\n" ro
  352.                     format "--\tr: %\n" r
  353.                     format "\n"
  354.                 )
  355.                 return false
  356.             )
  357.         )
  358.     
  359.         -----------------------------------------------
  360.         -- fnOpenRollOut()
  361.         -----------------------------------------------
  362.         fn fnOpenRollOut ro keys:1 = (             local tmp
  363.             local r        = fnFindRollOut ro
  364.  
  365.             if _DEBUG_ do format "fnOpenRollOut  - ro: %\tr: %\n" ro r
  366.             
  367.             try (
  368.                 try (
  369.                     if not ( tmp = fnLoadINI2 ( r[2] + "Auto" ) ) do tmp = false
  370.                     ro.btnAuto.checked = tmp
  371.  
  372.                     for n = 1 to r[3] do ro.fnUpdate keyIDX:n read:true 
  373.                  ) catch ()
  374.  
  375.                 if not ( tmp = fnLoadINI2 ( r[2] + "RolledUp" ) ) do tmp = false
  376.                 ro.open = not tmp
  377.  
  378.                 return true
  379.             ) catch (
  380.                 if _DEBUG_ do (
  381.                     format "-- Error: fnOpenRollOut()\n"
  382.                     format "--\tro: %\n" ro
  383.                     format "--\tkeys: %\n" keys
  384.                     format "--\tr: %\n" r
  385.                     format "--\ttmp: %\n" tmp
  386.                     format "--\tn: %\n" n
  387.                     format "\n"
  388.                 )
  389.                 fnCloseRollOut ro
  390.                 return false
  391.             )         )
  392.  
  393.         -----------------------------------------------
  394.         -- fnSetDefs()
  395.         -----------------------------------------------
  396.         fn fnSetDefs key val = (
  397.             try (
  398.                 setINISetting _defFile _defSect key val
  399.                 return true
  400.             ) catch (
  401.                 if _DEBUG_ do (
  402.                     format "-- Error: fnSetDefs()\n"
  403.                     format "--\tkey: %\n" key
  404.                     format "--\tval: %\n" val
  405.                     format "--\t_defFile: %\n" _defFile
  406.                     format "--\t_defSect: %\n" _defSect
  407.                     format "\n"
  408.                 )
  409.                 return false
  410.             )
  411.         )
  412.  
  413.         -----------------------------------------------
  414.         -- fnGetDefs()
  415.         -----------------------------------------------
  416.         fn fnGetDefs key = (
  417.             local val
  418.             try (
  419.                 val = ( execute ( getINISetting _defFile _defSect key ) )
  420.                 return val
  421.             ) catch (
  422.                 if _DEBUG_ do (
  423.                     print "-- Error: fnGetDefs()"
  424.                     format "--\tkey: %\n" key
  425.                     format "--\tval: %\n" val
  426.                     format "--\t_defFile: %\n" _defFile
  427.                     format "--\t_defSect: %\n" _defSect
  428.                     format "\n"
  429.                 )
  430.                 return false
  431.             )
  432.         )
  433.  
  434.         -----------------------------------------------
  435.         -- fnAcquire()
  436.         -----------------------------------------------
  437.         fn fnAcquire ro keys:1 = (
  438.             try (
  439.                 if ro.btnAcq.checked do (
  440.                     ro.btnAcq.enabled = false
  441.                     local acqObj = pickObject()
  442.     
  443.                     if not acqObj == undefined do if ro == _rollouts[1][1] then
  444.                         for r in _rollouts do if r[4] do
  445.                             for n = 1 to r[3] do r[1].fnUpdate keyIDX:n acq:true acqObj:acqObj
  446.                     else
  447.                         for n = 1 to keys do ro.fnUpdate keyIDX:n acq:true acqObj:acqObj
  448.     
  449.                     ro.btnAcq.enabled = true
  450.                     ro.btnAcq.checked = false
  451.                 )
  452.                 return true
  453.             ) catch (
  454.                 if _DEBUG_ do (
  455.                     format "-- Error: fnAcquire()\n"
  456.                     format "--\tro: %\n" ro
  457.                     format "--\tkeys: %\n" keys
  458.                     format "--\tacqObj: %\n" acqObj
  459.                     format "--\tn: %\n" n
  460.                     format "\n"
  461.                 )
  462.                 return false
  463.             )         )
  464.     
  465.         -----------------------------------------------
  466.         -- fnColor()
  467.         -----------------------------------------------
  468.         fn fnColor ro val:0 type:true keyIDX:1 = (
  469.             try (
  470.                 if type then (
  471.                     ro.spnClrR.value    = val.r as integer
  472.                     ro.spnClrG.value    = val.g as integer
  473.                     ro.spnClrB.value    = val.b as integer
  474.                 ) else 
  475.                     ro.clrLight.color    = [ ro.spnClrR.value, ro.spnClrG.value, ro.spnClrB.value ] as color
  476.                 ro.fnUpdate keyIDX:keyIDX
  477.                 return true
  478.             ) catch (
  479.                 if _DEBUG_ do (
  480.                     format "-- Error: fnColor()\n"
  481.                     format "--\tro: %\n" ro
  482.                     format "--\tval: %\n" val
  483.                     format "--\ttype: %\n" type
  484.                     format "--\tkeyIDX: %\n" keyIDX
  485.                     format "--\tacqObj: %\n" acqObj
  486.                     format "\n"
  487.                 )
  488.                 return false
  489.             )
  490.         )
  491.     
  492.         -----------------------------------------------
  493.         -- fnGetPropsToShow()
  494.         -----------------------------------------------
  495.         fn fnGetPropsToShow = (
  496.             try (
  497.                 local pteroBuffer = case selection.count of (
  498.                     1 : getUserPropBuffer $
  499.                     default : ""
  500.                 )
  501.                 fnSetControlValue _rollouts[2][1] _rollouts[2][1].controls[2] pteroBuffer
  502.                 return true
  503.             ) catch (
  504.                 if _DEBUG_ do (
  505.                     format "-- Error: fnGetPropsToShow()\n"
  506.                     format "--\tpteroBuffer: %\n" pteroBuffer
  507.                     format "--\tselection: %\n" $
  508.                     format "\n"
  509.                 )
  510.                 return false
  511.             )
  512.         )
  513.     
  514.         -----------------------------------------------
  515.         -- fnPrintLabel()
  516.         -----------------------------------------------
  517.         fn fnPrintLabel = (
  518.             try (
  519.                 local i = 0
  520.                 local sName = "S: "
  521.                 local sFace = "F: "
  522.                 case selection.count of (
  523.                     0 : (
  524.                             sName += "None"
  525.                             sFace += "0"
  526.                         )
  527.                     1 : (
  528.                             sName += $.name
  529.                             sFace += try ( ( $.mesh.numfaces ) as string ) catch ( "" )
  530.                         )
  531.                     default : (
  532.                             for n in selection do i += try ( n.mesh.numfaces ) catch ( 0 )
  533.                             sName += selection.count as string + " selected"
  534.                             sFace += i as string
  535.                         )
  536.                 )
  537.                 fnSetControlValue _rollouts[1][1] _rollouts[1][1].controls[1] ( fnCutString s:sName c:25 )
  538.                 fnSetControlValue _rollouts[1][1] _rollouts[1][1].controls[2] ( fnCutString s:sFace c:19 )
  539.                 return true
  540.             ) catch (
  541.                 if _DEBUG_ do (
  542.                     format "-- Error: fnPrintLabel()\n"
  543.                     format "--\tselection: %\n" $
  544.                     format "--\tsName: %\n" sName
  545.                     format "--\tsFace: %\n" sFace
  546.                     format "--\ti: %\n" i
  547.                     format "\n"
  548.                 )
  549.                 return false
  550.             )
  551.         )
  552.         
  553.         -----------------------------------------------
  554.         -- include rollouts
  555.         -----------------------------------------------
  556.         include "$scripts\\pteroTools\\_aboutRollOut.ms"
  557.         include "$scripts\\pteroTools\\plug_tmp_inc.ms"
  558.  
  559.         -----------------------------------------------
  560.         -- rollout MainRollOut
  561.         -----------------------------------------------
  562.         rollout MainRollOut    "PteroProps Panel" rolledUp:false (-- width:179 (
  563.             subrollout    sroWindow1                offset:[-10,0]                    width:(_mainWidth-4)
  564.             subrollout    sroWindow2                offset:[(_mainWidth-10),-19]    width:(_mainWidth-4)
  565.             subrollout    sroWindow3                offset:[(2*_mainWidth-10),-19]    width:(_mainWidth-4)
  566.             subrollout    sroWindow4                offset:[(3*_mainWidth-10),-19]    width:(_mainWidth-4)
  567.             
  568.             --------------------------------------------------------
  569.             --    fnWhichRow()
  570.             --------------------------------------------------------
  571.             fn fnWhichRow r = 
  572.                 case r of (
  573.                     1:    return MainRollOut.sroWindow1
  574.                     2:    return MainRollOut.sroWindow2
  575.                     3:    return MainRollOut.sroWindow3
  576.                     4:    return MainRollOut.sroWindow4
  577.                 )
  578.     
  579.             --------------------------------------------------------
  580.             --    fnAddRollOut()
  581.             --------------------------------------------------------
  582.             fn fnAddRollOut r:undefined s:false o:false = (
  583.                 local ro_subs    = #( #(), #(), #(), #() )
  584.                 local sro        = undefined
  585.                 local k            = 1
  586.                 local btn_names    = #()
  587.                 local ro
  588.                 
  589.                 for i in _rollouts do if r != undefined do
  590.                     if (fnDncase i[2]) == (fnDncase r) do sro = i
  591.                 
  592.                 if sro != undefined do (
  593.                     
  594.                      if _DEBUG_ do format "\nfnAddRollOut   - sro: %\n" sro
  595.                     
  596.                     if o do if ( s = fnLoadINI2 ( ( sro[1].name as string ) + "Show" ) ) == ok do s = true
  597.                     
  598.                     if s then (                                         -- Add rollout to the last free row
  599.                         do (
  600.                             ro = fnWhichRow k
  601.                             if ro.rollouts.count == 0 do exit
  602.                         ) while ( k += 1 ) < ( _usedRows + 1 )
  603.                         addSubRollout ro sro[1]
  604.                     ) else (                                        -- Remove rollout from row
  605.                         do (
  606.                             ro = fnWhichRow k
  607.                             if ro.rollouts.count == 0 do exit
  608.                             if ( findItem ro.rollouts sro[1] ) > 0 do exit
  609.                         ) while ( k += 1 ) < ( _usedRows + 1 )
  610.                         removeSubRollout ro sro[1]
  611.                     )
  612.     
  613.                     ro    = fnWhichRow 1
  614.  
  615.                     include "$scripts\\pteroTools\\plug_tmp_bta.ms"
  616.  
  617.                     for b in btn_names do
  618.                         if (fnDncase b[1]) == (fnDncase r) do (
  619.                             if o do b[2].checked = s
  620.                             fnSaveINI2 ( ( sro[1].name as string ) + "Show" ) ( ( b[2].checked ) as string )
  621.                         )
  622.                 )
  623.     
  624.                 if _usedRows > 1 do (
  625.                     for k = 1 to _maxRows do (                         -- Add all rollouts to the last used row array
  626.                         ro = fnWhichRow k
  627.                         for i = 1 to ro.rollouts.count do
  628.                             append ro_subs[_usedRows] ro.rollouts[i]
  629.                     )
  630.     
  631.                     for k = 1 to ( _usedRows - 1 ) do (             -- Move rollouts between row arrays
  632.                         ro = fnWhichRow k
  633.                         h = 0
  634.                         while ( h <= ro.height ) do (
  635.                             if ro_subs[_usedRows][1] == undefined do exit
  636.                             h += if ro_subs[_usedRows][1].open == true then ro_subs[_usedRows][1].height else 20
  637.                             if h > ro.height do exit
  638.                             append ro_subs[k] ro_subs[_usedRows][1]
  639.                             deleteItem ro_subs[_usedRows] 1
  640.                         )
  641.                     )
  642.     
  643.                     for k = 1 to _maxRows do (                        -- Remove rollouts from rows
  644.                         ro = fnWhichRow k
  645.                         for i = 1 to ro.rollouts.count do
  646.                             if ro.rollouts[i] != undefined and ro_subs[k][i] != ro.rollouts[i] do removeSubRollout ro ro.rollouts[i]
  647.                     )
  648.                     
  649.                     for k = 1 to _usedRows do (                        -- Add rollouts from row arrays to rows
  650.                         ro = fnWhichRow k
  651.                         for i = 1 to ro_subs[k].count do
  652.                             if ro_subs[k][i] != undefined and ( findItem ro.rollouts ro_subs[k][i] ) == 0 do addSubRollout ro ro_subs[k][i]
  653.                     )
  654.                 )
  655.             )
  656.  
  657.             -----------------------------------------------
  658.             -- rollout ShowPropsRollOut
  659.             -----------------------------------------------
  660.             rollout ShowPropsRollOut    "Properties Info" rolledUp:true (
  661.                 local _name
  662.                 local _RollOut
  663.     
  664.                 ---------------------------------------------------------------
  665.                 -- init GUI
  666.                 ---------------------------------------------------------------
  667.                 group "" (
  668.                     label    lblProps                width:144    height:260    align:#center offset:[0,-8]
  669.                 )
  670.  
  671.                  ---------------------------------------------------------------
  672.                 -- Init RollOut
  673.                 ---------------------------------------------------------------
  674.                  fn fnKeyNames    = #( _name )
  675.                  fn fnKeyUI        = #( #() )
  676.                  fn fnKeyDef        = #( #() )
  677.                 fn fnName        = "ShowProps"
  678.                 fn fnRollOut    = ShowPropsRollOut
  679.                 fn fnInitRollOut = (
  680.                     local _name        = fnName()
  681.                     local _RollOut    = fnRollOut()
  682.                     fnAppendRollOut _RollOut _name c:false
  683.                 )
  684.                 
  685.                 ---------------------------------------------------------------
  686.                 -- Event Handler
  687.                 ---------------------------------------------------------------
  688.                 on ShowPropsRollOut    open    do (
  689.                     _RollOut    = fnRollOut()
  690.                     _name        = fnName()
  691.                     fnOpenRollOut _RollOut keys:0
  692.                     fnGetPropsToShow()
  693.                  )
  694.                 on ShowPropsRollOut    close    do fnCloseRollOut _RollOut
  695.             )
  696.  
  697.             -----------------------------------------------
  698.             -- rollout ButtonsRollOut
  699.             -----------------------------------------------
  700.             rollout RolloutsRollOut    "Rollouts" rolledUp:false (
  701.                 local _name
  702.                 local _RollOut
  703.     
  704.                 ---------------------------------------------------------------
  705.                 -- init GUI
  706.                 ---------------------------------------------------------------
  707.                 label            lbl1        "S:"                        width:(_mainWidth / 1.3)                align:#left
  708.                 label            lbl2        "F:"                        width:(_mainWidth / 1.3)                align:#left
  709.                 include "$scripts\\pteroTools\\plug_tmp_btn.ms"
  710. --                checkbox        chkbox1        "Auto rollouts"    align:#center    enabled:false
  711.                 button            btnrefresh    "...:::  REFRESH  :::..."    width:(_mainWidth / 1.3)    height:20    align:#center
  712.  
  713.                 group "Apply to All" (
  714.                     button        btnSet        "Set"                images:_setIcon    width:27    height:18    offset:[0,0]    across:5    toolTip:"Set All Properties"
  715.                     checkbutton    btnAcq        "Acquire"            images:_acqIcon    width:27    height:18    offset:[0,0]                toolTip:"Acquire All Properties From Node ..."
  716.                     button        btnDef        "Template"            images:_defIcon    width:27    height:18    offset:[0,0]                toolTip:"Use All Templates"
  717.                     button        btnSav        "Save Template"        images:_savIcon    width:27    height:18    offset:[0,0]                toolTip:"Save All Templates"
  718.                     button        btnDel        "Delete"            images:_delIcon    width:27    height:18    offset:[0,0]                toolTip:"Delete All Properties"
  719.                 )
  720.  
  721.                  ---------------------------------------------------------------
  722.                 -- Init RollOut
  723.                 ---------------------------------------------------------------
  724.                  fn fnKeyNames    = #( _name )
  725.                  fn fnKeyUI        = #( #() )
  726.                  fn fnKeyDef        = #( #() )
  727.                 fn fnName        = "Rollouts"
  728.                 fn fnRollOut    = RolloutsRollOut
  729.                 fn fnInitRollOut = (
  730.                     local _name        = fnName()
  731.                     local _RollOut    = fnRollOut()
  732.                     fnAppendRollOut _RollOut _name c:false
  733.                 )
  734.                 
  735.                 --------------------------------------------------------
  736.                 --    event handles
  737.                 --------------------------------------------------------
  738.                 on btnSet    pressed            do (
  739.                     for r in _rollouts do if r[4] do
  740.                         for n = 1 to r[3] do r[1].fnUpdate keyIDX:n write:true
  741.                     fnGetPropsToShow()
  742.                     fnPrintLabel()
  743.                 )
  744.                 on btnAcq    changed state    do (
  745.                     fnAcquire _RollOut
  746.                     fnGetPropsToShow()
  747.                     fnPrintLabel()
  748.                 )
  749.                 on btnDef    pressed            do (
  750.                     for r in _rollouts do if r[4] do
  751.                         for n = 1 to r[3] do r[1].fnUpdate keyIDX:n def:true
  752.                     fnGetPropsToShow()
  753.                     fnPrintLabel()
  754.                 )
  755.                 on btnSav    pressed            do (
  756.                     for r in _rollouts do if r[4] do
  757.                         for n = 1 to r[3] do r[1].fnUpdate keyIDX:n sav:true
  758.                 )
  759.                 on btnDel    pressed            do (
  760.                     for r in _rollouts do if r[4] do
  761.                         for n = 1 to r[3] do r[1].fnUpdate keyIDX:n del:true
  762.                     fnGetPropsToShow()
  763.                     fnPrintLabel()
  764.                 )
  765.                 on btnrefresh        pressed    do (
  766.                     for ro in _rollouts do if ro[4] do
  767.                         for n = 1 to ro[3] do ro[1].fnUpdate keyIDX:n read:true 
  768.                     fnGetPropsToShow()
  769.                     fnPrintLabel()
  770.                 )
  771.                 on RolloutsRollOut    open    do (
  772.                     _RollOut    = fnRollOut()
  773.                     _name        = fnName()
  774.                     fnOpenRollOut _RollOut keys:0
  775.                     fnGetPropsToShow()
  776.                     fnPrintLabel()
  777.                 )
  778.                 on RolloutsRollOut    close    do fnCloseRollOut _RollOut
  779.             )
  780.     
  781.             on mainRollout lbuttondown s do fnAddRollOut()
  782.             --------------------------------------------------------
  783.             --    main rollout resized and moved handle
  784.             --------------------------------------------------------
  785.             on mainRollOut resized s do    (
  786.                                             mainRollOut.width = fnCompWidth s.x
  787.                                             mainRollout.height = if s.y < _mainHeight then _mainHeight else s.y
  788.                                             mainRollout.sroWindow1.height = mainRollout.height - _mainOffset
  789.                                             mainRollout.sroWindow2.height = mainRollout.sroWindow3.height = mainRollout.sroWindow4.height = mainRollout.height - _mainOffset --+ 42
  790.                                             fnAddRollOut()
  791.                                         )
  792.             on mainRollout moved s    do fnAddRollOut()
  793.             --------------------------------------------------------
  794.             --    main rollout open handle
  795.             --------------------------------------------------------
  796.             on mainRollout open        do    (
  797.                                             if ( w = fnLoadINI2 "DialogWidth" ) == ok then w = _mainWidth else w = fnCompWidth w
  798.                                             mainRollOut.width = w
  799.                                             mainRollout.sroWindow1.height = mainRollout.height - _mainOffset
  800.                                             mainRollout.sroWindow2.height = mainRollout.sroWindow3.height = mainRollout.sroWindow4.height = mainRollout.height - _mainOffset --+ 42
  801.                                             ---------------------------------------------------------------
  802.                                             ---------------------------------------------------------------
  803. /*                                            fnAppendRollOut aboutRollOut "About" c:false
  804.                                             fnAppendRollOut ShowPropsRollOut "ShowProps" c:false
  805.                                             fnAppendRollOut RolloutsRollOut "RollOuts" c:false
  806. */                                            aboutRollOut.fnInitRollOut()
  807.                                             ShowPropsRollOut.fnInitRollOut()
  808.                                             RolloutsRollOut.fnInitRollOut()
  809.                                             ---------------------------------------------------------------
  810.                                             ---------------------------------------------------------------
  811.                                             for r in _rollouts do fnAddRollOut r:r[2] s:true o:true
  812.  
  813.                                             _isPteroPropsOpen = true
  814.                                         )
  815.             --------------------------------------------------------
  816.             --    main rollout close handle
  817.             --------------------------------------------------------
  818.             on mainRollout close    do    (
  819.                                             fnSaveINI2 "DialogHeight"    ( mainRollout.height as string )
  820.                                              fnSaveINI2 "DialogWidth"    ( mainRollout.width as string )
  821.                                             fnSaveINI2 "DialogPosition" ( ( getDialogpos mainRollout ) as string )
  822.  
  823.                                             _isPteroPropsOpen = false
  824.                                         )
  825.         )
  826.     
  827.         if ( p = fnLoadINI2 "DialogPosition" ) == ok do p = [50,50]
  828.         if ( h = fnLoadINI2 "DialogHeight" ) == ok do h = _mainHeight
  829.         createDialog mainRollOut style:#(#style_toolwindow, #style_sysmenu, #style_resizing) width:_mainWidth height:(if h < _mainHeight then _mainHeight else h) pos:p
  830.     )
  831. )
  832.  
  833. macroscript PteroFaceCheck category:"PteroTools"
  834. buttonText:"Face Check"
  835. toolTip:"Check Crashed Faces"
  836. icon:#("pteroTools", 2)
  837. (
  838.     fnFindSpikeFaces()
  839. )
  840.  
  841. macroscript PteroColMatList category:"PteroTools"
  842. buttonText:"PteroCol Materials List"
  843. toolTip:"List of PteroCol Materials"
  844. icon:#("pteroTools", 3)
  845. (
  846.     fnColMatList()
  847. )
  848.